package com.zhongke.cotrun.controller.manager;

import com.zhongke.cotrun.common.util.APIResponse;
import com.zhongke.cotrun.mapper.IntegralOfTypeMapper;
import com.zhongke.cotrun.model.pojo.IntegralOfType;
import com.zhongke.cotrun.model.resultpackage.CodeMsg;
import com.zhongke.cotrun.service.IntegralOfTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/manager/Integral")
public class IntegralOfTypeController {

    @Autowired
    IntegralOfTypeService integralOfTypeService;

    /**
     * 新增积分所属类别
     * @param integralOfType
     * @return
     */
    @PostMapping("/insertIntegralOfType")
    public APIResponse insertIntegralOfType(IntegralOfType integralOfType){
      if(integralOfTypeService.insertIntegralOfType(integralOfType)) {
          return APIResponse.returnSuccess();
      }
        return APIResponse.returnFail(CodeMsg.ADD_ERROR);
    }

    /**
     * 查看所有的积分所属类型
     * @return
     */
    @GetMapping("/selectAllIntegralOfType")
    public APIResponse selectAllIntegralOfType(){
        return APIResponse.returnSuccess(integralOfTypeService.selectIntegralOfType(1));
    }


}
